/**
 * 车辆发车相关明细查询
 * @author miaoyl
 * @date 2019/12/17
 */
define(function () {

    var self,
        app = win.app,
        doc = document,
        layui = win.layui,
        table,
        element,
        vueData = {

        },
        table_where = {

        },
        cols = [[
              {field: 'PMAA291', width: 120, title: '大区', fixed: 'left'}
            , {field: 'PMAA292', width: 100, title: '省份', fixed: 'left'}
            , {field: 'XMDA002', width: 120, title: '业务人员', sort: true}
            , {field: 'GWCAORIG_NAME', width: 120, title: '归属部门', sort: true}
            , {field: 'XMDAUA020', width: 80, title: '订单类型',sort: true,
                filterDatas:app.datas_('crm_gwci001_gwca002'),
                search: 'default',searchOpts: {type: 'select'}
            }
            , {field: 'FCLX', width: 80, title: '发车属性',sort: true,
                filterDatas:app.datas_('crm_gwci002_fclx'),
                search: 'default',searchOpts: {type: 'select'}
            }
            , {field: 'XMDASITE_NAME', width: 100, title: '签订单位',sort: true}
            , {field: 'GWCA006_NAME', width: 100, title: '客户单位',sort: true,
                search: 'default'
            }
            , {field: 'GWAK009', width: 100, title: '组织形式',sort: true,
                filterDatas:app.datas_('crm_gwai300_gwak009')
            }
            , {field: 'XMDAUA001', width: 100, title: '合同编号',sort: true,
                search: 'default', searchOpts: {icon:true,readonly:true}
            }
            , {field: 'GWAHL003', width: 100, title: '产品大类'}
            , {field: 'GWAOL003', width: 100, title: '车辆类型'}
            , {field: 'IMAAL004', width: 160, title: '车型',
                search: 'default', searchOpts: {icon:true,readonly:true}
            }
            /*, {field: 'XMDA004', width: 80, title: '购车单位'}*/
            , {field: 'XMDK009', width: 80, title: '最终用户'}
            , {field: 'XMDC015', width: 80, title: '单价(万元)'}
            , {field: 'TS', width: 80, title: '台数'}
            , {field: 'XMDCUA003', width: 80, title: '喷涂',
                filterDatas:app.datas_('sys_n_y')
            }
            , {field: 'XMDCUA002', width: 120, title: '配置'}
            , {field: 'XMDCUA002', width: 120, title: '车辆配置明细'}
            , {field: 'XMDCUA004', width: 120, title: '喷涂样式'}
            , {field: 'GWCA007', width: 80, title: '生产批号'}
            , {field: 'SFAAUA001', width: 150, title: '顺序号'}
            , {field: 'SFAAUC013', width: 120, title: '发动机号'}
            , {field: 'SFAAUC022', width: 80, title: '车辆识别码',
                search: 'default'
            }
            , {field: 'SFAAUC015', width: 120, title: '出厂编号'}
            , {field: 'SFAAUC023', width: 100, title: '车辆颜色'}
            , {field: 'QCBBUC002', width: 160, title: '车辆(整车)合格证编号'}
            , {field: 'QCBBUC004', width: 160, title: '整车合格证发证时间'}
            , {field: 'XMDLUC002', width: 80, title: '发车日期'}
            , {field: 'XMDLUC003', width: 120, title: '目的地省份'}
            , {field: 'XMDLUC004', width: 120, title: '目的地市级'}
            , {field: 'XMDLUC005', width: 120, title: '临时牌号'}
            , {field: 'XMDLUC006', width: 120, title: '临时牌办理日期'}
            , {field: 'XMDLUC007', width: 120, title: '临时牌截止日期'}
            , {field: 'XMDLUC008', width: 120, title: '临时牌费用'}
            , {field: 'XMDLUC009', width: 120, title: '临时牌保险费用'}
            , {field: 'XMDLUC010', width: 120, title: '承运单位'}
            , {field: 'XMDLUC011', width: 120, title: '承运方式'}
            , {field: 'XMDLUC012', width: 120, title: '承运原因'}
            , {field: 'XMDLUC013', width: 120, title: '驾驶员'}
            , {field: 'XMDLUC014', width: 120, title: '入库日期'}
            , {field: 'XMDLUC015', width: 120, title: '备胎'}
            , {field: 'XMDLUC016', width: 120, title: '实际发车日期'}
            , {field: 'XMDLUC017', width: 120, title: '车辆情况'}
            , {field: 'XMDLUC018', width: 120, title: '箱体编号'}
            , {field: 'XMDLUC019', width: 120, title: '返厂时间'}
            , {field: 'XMDLUC020', width: 120, title: '公开信息编码(环保清单编码)'}
            , {field: 'XMDLUC021', width: 120, title: '出厂试验'}
            , {field: 'XMDLUC022', width: 120, title: '开票时间'}
            , {field: 'XMDLUC023', width: 120, title: '发票类别'}
            , {field: 'XMDLUC024', width: 120, title: '发票编号'}
            , {field: 'XMDLUC025', width: 120, title: '快递编号'}
            , {field: 'XMDLUC026', width: 120, title: '属于市、区'}
            , {field: 'XMDLUC027', width: 120, title: '送车员'}
            , {field: 'XMDLUC028', width: 120, title: '单价'}
            , {field: 'XMDLUC029', width: 120, title: '公里数'}
            , {field: 'XMDLUC030', width: 120, title: '补贴'}
            , {field: 'XMDLUC031', width: 120, title: '送车费结算金额'}
            , {field: 'XMDLUC032', width: 120, title: '补贴说明'}
            , {field: 'XMDLUC033', width: 120, title: '核算时间'}
            , {field: 'XMDLUC034', width: 120, title: '交接清单编号'}
            , {field: 'XMDLUC035', width: 120, title: '回收情况'}
            , {field: 'XMDLUC036', width: 120, title: '承运清单'}
        ]],
        moduleName = '车辆发车相关明细'
    ;

    var gwcq002 = app.Module.extend({
        init: function () {
            self = this;
           /* var _searchsArr = app.cloneJSON(cols[0]);*/
            self._super({
                _tag: 'gwcq002',
                _searchs: [{
                    id: 'gwcq002', tableId: 'gwcq002_table', datas: cols[0]
                }],
                _loadTplsFull: [
                    {dom: 'common_open_window', tpl: 'common/_open_window'}
                ]
            }, win);
        },

        initTable: function () {
            layui.use(['table'], function () {
                table = layui.table;
                table.render({
                    elem: app.getByid(doc, 'gwcq002_table'),
                    url: g_ctxPath + 'crm/gwcq002/getGwcq002List',
                    exportsUrl: g_ctxPath + 'crm/gwcq002/exportsData',
                    exportsName: moduleName + '数据',
                    title: moduleName + '表',
                    method: 'post',
                    id: 'gwcq002_table',
                    size: _layuiConfig.ui_size,
                    autoSort: false, //禁用前端自动排序
                    toolbar: '#table-toolbar',
                    defaultToolbar: ['filter', 'exports'],
                    height: 'full',
                    cols: cols,
                    loading: true,
                    page: true,
                    where: table_where,
                    done: function (res, curr, count) {

                    }
                });
            });

            var tipsIndex = null;

            $(doc).on('click', function () {
                tipsIndex && layer.close(tipsIndex);
            });
        },

        reloadTableCurr: function () {
            self._reloadTable({id: 'gwcq002_table', where: table_where});
        },

        _ready: function () {
            this._super({
                vue: [{
                    el: '#page',
                    data: '',
                    searchId: 'gwcq002',
                    methods: {
                        handleIconClick: function (field) {
                            var vue = this;
                            if (field == 'IMAAL004') {//车型开窗
                                self._openTplFull({
                                    tag: 'common_open_window',
                                    tagData: {
                                        config: {
                                            method:'q_gwam001',
                                            columnList: [
                                                {label: '车型', prop: 'GWAM001', width: '150'}
                                            ],
                                        },
                                        cb: function (data) {
                                            vue.isearch.fields.IMAAL004 = data.GWAM001;
                                        }
                                    },
                                    index: 0,
                                    openOpts: {
                                        title: '选择车型',
                                        area: ['600px', '470px']
                                    }
                                });
                            } else if (field == 'XMDAUA001') {//合同编号
                                self._openTplFull({
                                    tag: 'common_open_window',
                                    tagData: {
                                        config: {
                                            method:'q_gwca005',
                                            columnList: [
                                                {label: '合同编号', prop: 'GWCA005', width: '150'},
                                                {label: '合同签订组织', prop: 'GWCAMLEGAL_NAME', width: '150'}
                                            ],
                                        },
                                        cb: function (data) {
                                            vue.isearch.fields.XMDAUA001 = data.GWCA005;
                                        }
                                    },
                                    index: 0,
                                    openOpts: {
                                        title: '选择合同编号',
                                        area: ['600px', '465px']
                                    }
                                });
                            }
                        }
                    },
                    watch:{

                    },
                    created: function(){

                    }
                }]
            });

            self.initTable();
        },
        _lazy: function () {
            this._super();
            layui.use(['table'], function () {
                element = layui.element;
            });
        }
    });

    return new gwcq002();

});
